package com.cloudm.technician.ui.base

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.support.v4.app.DialogFragment

/**
 * 作者: wesley
 * 时间: 2017/11/20
 * 描述: 基类的对话框
 */
abstract class BaseDialogFragment: DialogFragment() {

    protected lateinit var mContext: Context

    override fun onAttach(context: Context?) {
        super.onAttach(context)
        context?.let {
            this.mContext = it
        }
    }


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        handleArguments()
    }


    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog = createDialog()


    private fun handleArguments() {
        arguments?.let {
            handleBundle(it)
        }
    }


    protected abstract fun handleBundle(bundle: Bundle)


    protected abstract fun createDialog(): Dialog

}